#include <iostream>
#include <string>
class RoundPeg
{
protected:
    int radius;
    std::string name;
public:
    RoundPeg()
    {

    }
    explicit RoundPeg(int radius, std::string name)
    {
        RoundPeg::radius = radius;
        RoundPeg::name = name;
    }
    virtual int getRadius()
    {
        return radius;
    }
    virtual std::string getName()
    {
        return name;
    }
};

class RoundHole
{
private:
    int radius;
    std::string name;
public:
    explicit RoundHole(int radius, std::string name)
    {
        RoundHole::radius = radius;
        RoundHole::name = name;
    }
    int getRadius()
    {
        return radius;
    }
    bool fits(RoundPeg* peg)
    {
        bool result = peg->getRadius() == radius;
        if(result)
            std::cout<<name<<" fits " << peg->getName()<<std::endl;
        return result;
    }
};

class SquarePeg
{
private:
    int width;
    std::string name;
public:
    explicit SquarePeg(int width, std::string name)
    {
        SquarePeg::width = width;
        SquarePeg::name = name;
    }
    int getWidth()
    {
        return width;
    }
    std::string getName(){
        return name;
    }
};

class SquarePegAdapter: public RoundPeg
{
private:
    SquarePeg* squarePeg = nullptr;
public:
    explicit SquarePegAdapter(SquarePeg* squarePeg)
    {
        SquarePegAdapter::squarePeg = squarePeg;
    }
    int getRadius() override
    {
        return squarePeg->getWidth()/2;
    }
    std::string getName() override
    {
        return squarePeg->getName();
    }
};

int main() {
    RoundHole* roundHole = new RoundHole(100, "RoundHole");
    SquarePeg* squarePeg = new SquarePeg(200, "SquarePeg");
    RoundPeg* roundPeg1 = new RoundPeg(100, "RoundPeg");
    SquarePegAdapter* roundPeg = new SquarePegAdapter(squarePeg);
    roundHole->fits(roundPeg);
    return 0;
}



